<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>原生ajax</title>
  <script>
    let baseURL = 'http://47.94.46.113:7788'
    let loginData = {
      username: 'admin1',
      password: '123321'
    }
    // 1.实例化xhr
    let xhr = new XMLHttpRequest()
    // 2.配置请求信息，打开链接
    xhr.open('post', baseURL + '/user/login')
    // xhr.setRequestHeader('Content-Type', 'application/json')
    // 3.发送请求，并且配置请求体中的数据
    xhr.send(JSON.stringify(loginData))
    // 4.监听链接状态的改变
    xhr.onreadystatechange = function () {
      if (xhr.readyState == 4 && xhr.status == 200) {
        console.log(xhr.response);
      }
    }
  </script>
</head>

<body>

</body>

</html>